POV-Ray : Newsgroups : povray.general : Request for enhancement : Re: Request for enhancement Server Time
8 Aug 2024 14:22:24 EDT (-0400)
  Re: Request for enhancement  
From: Chris Colefax
Date: 2 Dec 2000 21:56:02
Message: <3a29b642@news.povray.org>
=Bob= <Bob### [at] threestrandscom> wrote:
> I'd really like it if PovRay had assignment operators,
> so that it would know the difference between declaring
> a variable and assigning a value to an existing one. It
> would, in my case, signal a typo for the multitude of
> variables used in some of my code. I like to declare
> the default variables and then change them as needed
> prior to calling macros.
>
> #declare gl_XposAtMaxVelocity = 1.45;
>
> later in the code:
>
> #assign gl_XPosAtMaxVelocity = 2.00;
>
> Then PovRay would check the existence of the previously
> declared variable and issue a warning that the variable
> does not exist. In the example above, I have a capital 'P'
> where it should be lower case.
>
> Currently, PovRay just creates the new variable and the
> macro continues to use the old value and it's sometimes
> difficult to find the error.

Why patch POV when you can do it with macros?:

#macro assign (Var, Value) #declare Var = Value; #end

Usage:

#declare gl_XposAtMaxVelocity = 1.45;
assign (gl_XposAtMaxVelocity, 2.00)

This should behave exactly as you want, issuing a warning when you try to
assign a value to a non-defined variable (and even showing you the mistyped
variable name!).

If you want to go one step further, you can create macros that allow you to
use named options with macro functions (so you don't have to declare/assign
all the options you want to use) - see my Spline Macro File at
http://www.geocities.com/ccolefax/spline for details.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.